package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 制证订单
 * </p>
 *
 * @author ligang
 * @date 2023-07-07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateOrderOrderStatusEnum", description = "订单状态:#{NO_PAY:未支付;WAIT:支付中;PAY_FAIL:支付失败;PAY_SUCC:支付成功;-枚举")
public enum CertificateOrderOrderStatusEnum implements BaseEnum {

    /**
     * NO_PAY="未支付"
     */
    NO_PAY("未支付"),
    /**
     * WAIT="支付中"
     */
    WAIT("支付中"),
    /**
     * PAY_FAIL="支付失败"
     */
    PAY_FAIL("支付失败"),
    /**
     * PAY_SUCC="支付成功"
     */
    PAY_SUCC("支付成功"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateOrderOrderStatusEnum match(String val, CertificateOrderOrderStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateOrderOrderStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateOrderOrderStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "NO_PAY,WAIT,PAY_FAIL,PAY_SUCC", example = "NO_PAY")
    public String getCode() {
        return this.name();
    }

}
